Out: Monday, October 17, 2016
Due: Monday, October 24, 2016 at 600pm local time.
The goal of this problem set is to help you design and use multiply-recursive and mutually-recursive data definitions, and to give you practice using the list abstractions and higher-order functions.
Remember that you must follow the design recipe.
You must use DrScheme's HtDP Intermediate Student Language with Lambda.
As usual, the rubric for grading is here. Remember that you must follow the design recipe. Your deliverables include the data definitions (including interpretation and templates), contract and purpose header, halting measure (when needed), strategy, code, and tests. Be sure to sync your work and fill out a Work Session Report at the end of every work session. Use the Work Session Report for PS06.
You must also turn in a call graph for your program. As in the preceding problem set, this consists of a diagram showing which functions call which, so we (and you) can see the overall structure of your program. You may draw the diagram using a tool or by hand. Turn this in as a text file, pdf, jpg, or Racket file. Call your file call-tree with an appropriate suffix, and bring a paper copy to your codewalk.
You must include a halting measure for every function that calls itself either directly or indirectly. Be prepared to explain how your halting measure decreases around every cycle in the call graph for that function.
For all universe programs, you may assume that the mouse is never dragged or moved outside of the canvas. Once the mouse enters the canvas, if the mouse ever leaves the canvas, then the behavior of your system is unspecified.
Here's a demo.
Your solution should provide the following functions:
initial-world : Any -> World
GIVEN: any value
RETURNS: an initial world. The given value is ignored.
run : Any -> World
GIVEN: any value
EFFECT: runs a copy of an initial world
RETURNS: the final state of the world. The given value is ignored.
world-after-mouse-event : World Integer Integer MouseEvent -> World
GIVEN: a World, a location, and a MouseEvent
RETURNS: the state of the world as it should be following the given mouse event at that location.
world-after-key-event : World KeyEvent -> World
GIVEN: a World and a key event
RETURNS: the state of the world as it should be following the given key event
world-to-trees : World -> ListOfTree
GIVEN: a World
RETURNS: a list of all the trees in the given world.
tree-to-root : Tree -> Node
GIVEN: a tree
RETURNS: the node at the root of the tree
EXAMPLE: Consider the tree represented as follows:
A
|
+---+-----+-----+
| | | |
B C D E
| |
+---+ +-----+
| | | |
F G H I
If tree-to-root is given the subtree rooted at C, it should return the
data structure associated with node C. This data structure may or may
not include data associated with rest of the tree, depending on
whether you have chosen to represent nodes differently from trees.
tree-to-sons : Tree -> ListOfTree
GIVEN: a tree
RETURNS: the data associated with the immediate subtrees of the given
tree.
EXAMPLE: In the situation above, if tree-to-sons is given the subtree
rooted at C, it should return a list consisting of the subtree rooted
at F and the subtree rooted at G.
[Note how these examples are expressed. They are not just tests, but
are constructed to illuminate possible ambiguities or
misunderstandings in the purpose statement. This is what a good
example does.]
node-to-center : Node -> Posn
RETURNS: the center of the given node as it is to be displayed on the
scene.
Note: this function returns a Posn (an ISL builtin). This is for the
convenience of the testing framework, and you may or may not wish to
represent the center of the node in this way.
node-to-selected? : Node -> Boolean
RETURNS: true iff the given node is selected.
Hints:
Last modified: Thu Oct 20 11:07:28 Eastern Daylight Time 2016